package com.lsl.menglushishang.util;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class NetWorkUtil {
	
	private Context context;
	private static NetWorkUtil networkUtil;
	private NetWorkUtil(Context context){
		this.context = context;
	}
	public static NetWorkUtil getInstance(Context context){
		if(networkUtil==null){
			networkUtil = new NetWorkUtil(context);
		}
		return networkUtil;
	}
	
	public boolean checkNetWorkAvailable(){
		ConnectivityManager manager = (ConnectivityManager) context.getSystemService(context.CONNECTIVITY_SERVICE); 
		
		if(manager!=null){
			NetworkInfo networkInfo = manager.getActiveNetworkInfo();
			if(networkInfo==null || !networkInfo.isAvailable() || !networkInfo.isConnected()){
				return false;
			}else{
				return true;
			}
		}
		return false;
	}
	
}
